package com.yanqu.road.server.manager.activity.hsisland.handler.impl;

import com.yanqu.road.entity.activity.hsisland.HsIslandExploreResult;
import com.yanqu.road.entity.activity.hsisland.HsIslandUserLog;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandBuffConfig;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandConfig;
import com.yanqu.road.entity.activity.hsisland.data.HsIslandEventData;
import com.yanqu.road.entity.activity.hsisland.data.HsIslandMonsterData;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandEventIdEnum;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandMonsterTypeEnum;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandUserLogTypeEnum;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandYnFlagEnum;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivity;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandFloor;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandIsland;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandUser;
import com.yanqu.road.server.manager.activity.hsisland.handler.param.HsIslandExploreHandlerReq;
import com.yanqu.road.server.manager.activity.hsisland.handler.param.HsIslandExploreHandlerResp;
import com.yanqu.road.server.manager.activity.hsisland.handler.HsIslandIEventHandler;

public class HsIslandEventBuffHandler implements HsIslandIEventHandler {

    /**
     * 探索后处理
     * @param req
     * @return
     */
    @Override
    public HsIslandExploreResult explore(HsIslandExploreHandlerReq req) {
        CrossHsIslandActivity activity = req.getActivity();
        HsIslandConfig config = activity.getConfig();
        HsIslandEventData eventData = req.getEventData();
        CrossHsIslandUser user = req.getUser();
        CrossHsIslandIsland island = req.getIsland();
        //事件注入坐标
        eventData.addPosition(req.getX(), req.getY());
        //随机出一个buff
        HsIslandBuffConfig buffConfig = config.getWeightRandomBuff();
        eventData.setBuffId(buffConfig.getId());
        //玩家添加BUFF
        user.addBuff(buffConfig);
        //注入事件
        island.putEvent(eventData);
        //【BUFF】事件探索完就完结
        island.finishEvent(eventData);
        //个人日志-九宝琉璃事件
        HsIslandUserLog log = new HsIslandUserLog();
        log.setType(HsIslandUserLogTypeEnum.USER_LOG_TYPE_6.getType());
        log.setBuffId(buffConfig.getId());
        log.setTime(System.currentTimeMillis());
        user.addUserLog(log);
        //返回
        HsIslandExploreResult resp = new HsIslandExploreResult();
        resp.addEventData(eventData);
        return resp;
    }
}
